//
//  JLXXMineProductionCollectionCell.m
//  JLXXListController
//
//  Created by apple on 17/5/16.
//  Copyright © 2017年 cnsuer. All rights reserved.
//

#import "JLXXMineProductionCollectionCell.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "JLXXDefine.h"

#import "JLXXMinePhoto.h"
#import "JLXXMineVideo.h"
#import "JLXXMineRecording.h"

@interface JLXXMineProductionCollectionCell()

@property (nonatomic , strong) id item;

@end

@implementation JLXXMineProductionCollectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)setItem:(id)item forIndexPath:(NSIndexPath *)indexPath{
    self.item = item;
    NSURL *preImageViewUrl = nil;
    NSString *upload_dateLabel = nil;
    
    if ([item isKindOfClass:[JLXXMinePhoto class]]) {
        JLXXMinePhoto *mineProduction = (JLXXMinePhoto *)item;
        upload_dateLabel = mineProduction.upload_date;
        preImageViewUrl = [NSURL URLWithString:mineProduction.r_url];
        self.playIconImageView.hidden = YES;

    }else if ([item isKindOfClass:[JLXXMineVideo class]]) {
        JLXXMineVideo *mineProduction = (JLXXMineVideo *)item;
        upload_dateLabel = mineProduction.upload_date;
        preImageViewUrl = [NSURL URLWithString:mineProduction.thumb];
        self.playIconImageView.hidden = NO;
     
    }else if ([item isKindOfClass:[JLXXMineRecording class]]) {
        JLXXMineRecording *mineRecording = (JLXXMineRecording *)item;
        upload_dateLabel = mineRecording.add_time;
        preImageViewUrl = [NSURL URLWithString:mineRecording.thumb];
        self.playIconImageView.hidden = NO;
    }
    
    self.upload_dateLabel.text = upload_dateLabel;
    [self.preImageView sd_setImageWithURL:preImageViewUrl];
}
- (IBAction)opretationButtonClick:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(yzgCollectionCell:clickButtons:cellItem:)]) {
        [self.delegate yzgCollectionCell:self clickButtons:@[sender] cellItem:self.item];
    }
}

+(CGSize)collectionView:(UICollectionView *)collectionView itemSizeForItem:(id)item{
    CGFloat width = (KScreenWidth-10) /2.0;
    return CGSizeMake(width , width + 20);
}
@end
